package org.NooLab.itexx.retrieval.cms;

 
/**
 * This implementation class for pre- and postprocessing of google result pages
 * need not to know anything about the "content" of the interfaces (their implementation);
 * 
 * we achieved that by cross-linking interfaces between provider and consumer;
 * such it is a plugin
 * 
 */




import org.NooLab.itexx.retrieval.PageIntf;
import org.NooLab.itexx.retrieval.intf.DocumentsPPPIntf;
import org.NooLab.itexx.retrieval.intf.PPPConsumerIntf;
import org.NooLab.utilities.url.*;


/**
 * 
 * this class performs operations on the page of a typical CMS, such that  <br/>
 * - menu text is removed (optionally) and/or collated ,
 * - main text area is identified
 * - links from within the text are preferred against menu links
 * 
 * 
 */
public class CMSPreProc implements DocumentsPPPIntf{
	
	public CMSPreProc( PPPConsumerIntf consumer ){
		
		// this should send an anchor to the main class , such that this preproc routine
		// can be executed over there
		
		consumer.addPreProcessor( this ) ;
		
	}

	 
	public void performPPP( PageIntf page) {
		String str, pageAddress ;
		 
		
		try{
			
			pageAddress = page.getWebURL().getURL() ;

			// just for DEBUG page.setText( (String) ("<!--  abc -->" + page.getText()) ) ;
			
			 
			
			
			str = page.getHTML() ;
			
			// do the adjustments here
			
			
			
			
			// put the changes back to the page :: object
			
			page.setHTML(str) ;
			
			
		}catch(Exception e){
			e.printStackTrace() ;
		}	
		
		
	}
	
	/**
	 * 
	 * separate menus from main content
	 * 
	 * typo,joomla, drupal, wordpress, blogger,  
	 * 
	 */
	public String performPPP(String htmltext) {
		String str="";
		
		try{
			
			str = htmltext ;
			
		}catch(Exception e){
			
		}
		return str;
	}
	
	
	
}
